#ifndef COMMON_H_INCLUDED
#define COMMON_H_INCLUDED

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <iostream>
#include "commands.h"
#include <unistd.h>
#include "utils.h"

//------------------------
// Logging
//------------------------
struct nullstream : std::ostream {
    nullstream() : std::ios(0), std::ostream(0) {}
};
static nullstream logstream;
#define LOG  logstream
//#define LOG cerr
//------------------------


#define MAX_FILENAME_LENGTH     (260 + 5)
#define max_line_length         (2000)
#define max_message_length      (2000)
#define UDP_PORT_SERVER     (5555)
#define UDP_PORT_CLIENT     (5556)

typedef unsigned char byte;

void error(const char *str);

extern int socket_message;

int send_msg_to_address(std::string s, sockaddr_in address);

struct sockaddr_in generate_sockaddr_int(uint32_t address, uint16_t port);

int getPort(int socket);

void sendFile(std::string filename, uint32_t address, int port);
void sendFile(std::string filename, std::string servername, int port);

void receiveFile(std::string filename, int fileSize, struct sockaddr_in addr);

bool socketContainsData(int sock);



#endif
